# -*- coding: utf-8 -*-
# @Time 2025/1/21 17:12
# @Author 纳麦乌拉
# @File test.py

from ultralytics import YOLO
import cv2
class MyYolo:
    def __init__(self):
        self.model = YOLO("D:/gitee/yolo11/yolo11n.pt")
    def md(self):
        return self.model
yl=MyYolo()


# Load a pretrained YOLO11n model
model = yl.md() 

def pred(imgs):
    result=model.predict(imgs, save=False, imgsz=320, conf=0.5, show=False)
    return result

def test():
    # Run inference on 'bus.jpg' with arguments
    path="D:/gitee/yolo11/bus.jpg"
    image = cv2.imread(path, cv2.IMREAD_COLOR)
    image2 = cv2.imread(path, cv2.IMREAD_COLOR)
    imgs=[]
    imgs.append(image)
    imgs.append(image2)
    rs=pred(imgs)
    
    for r in rs:
        print("")
        print(r.boxes.cls )
        print(r.boxes.conf)
        for j in range(r.boxes.cls.size(0)):
            cs=r.boxes.cls[j]
            print(model.names[int(cs)])
            print(r.boxes.conf[j])
     

test()